{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cc0a8518-395e-442c-b12e-7903d3e3b141",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/find-peak-element\n",
    "\n",
    "\n",
    "Runtime: 4 ms, faster than 69.46% of C++ online submissions for Find Peak Element.\n",
    "Memory Usage: 8.9 MB, less than 47.62% of C++ online submissions for Find Peak Element.\n",
    "\n",
    "\n",
    "```cpp\n",
    "#include<bits/stdc++.h> \n",
    "\n",
    "using namespace std;\n",
    "\n",
    "class Solution {\n",
    "public:\n",
    "    int findPeakElement(vector<int>& nums) {\n",
    "        //7:18\n",
    "        int max_value = INT_MIN;\n",
    "        int possible_index = 0;\n",
    "        for (int i = 0; i < nums.size(); i++) {\n",
    "            if (nums[i] > max_value) {\n",
    "                max_value = nums[i];\n",
    "                possible_index = i;\n",
    "            }\n",
    "            if ((i != 0) && (i < nums.size()-1)) {\n",
    "                if ((nums[i-1] < nums[i]) && (nums[i+1] < nums[i])) {\n",
    "                    return i;\n",
    "                }\n",
    "            }\n",
    "        }\n",
    "        return possible_index;\n",
    "        //7:23\n",
    "    }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "50721784-f16c-4a0c-9812-1632b1561f13",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "name": ""
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
